﻿using System.Collections.Generic;
using K9Nano.Authorization;
using K9Nano.Dependency;
using K9Nano.Remoting;

namespace K9Nano.Application.Api
{
    public class ApiResourceAppService : IApiResourceAppService, ISingletonDependency
    {
        protected readonly IApiInfo ApiInfo;
        protected readonly IApiResourceProviderFactory ApiResourceProviderFactory;

        public ApiResourceAppService(IApiInfo apiInfo, IApiResourceProviderFactory apiResourceProviderFactory)
        {
            ApiInfo = apiInfo;
            ApiResourceProviderFactory = apiResourceProviderFactory;
        }

        public IReadOnlyList<IApiResource> GetResources()
        {
            return ApiResourceProviderFactory.Create(ApiInfo.Name).Resources;
        }
    }
}